#ifndef MASTER_H
#define MASTER_H
#pragma once

#if !defined(_MSC_VER) /* In Visual Studio you can change between Unicode and ASCII/ANSI by using the 4 predefined solution configurations,
												in Dev-Cpp you have to do it manually */

#define UNICODE
#define _UNICODE

#if defined(UNICODE) && !defined(_UNICODE) || defined(_UNICODE) && !defined(UNICODE)
#error Both UNICODE and _UNICODE must be defined
#endif /* Only one of UNICODE and _UNICODE is defined */

#endif /* _MSC_VER */

/* General Defines */

#ifndef UNICODE

#define _WIN32_WINNT 0x0400

#else

#define _WIN32_WINNT 0x0500

#endif

#define _WIN32_IE 0x0500
#define NO_DSHOW_STRSAFE /* so dshow.h doesn't include strsafe.h */
#define _WIN32_DCOM
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_RAND_S /* For rand_s in VS2005 */
#define ERRORM_DEBUG_ONLY /* These two defines are for the errormessages.h library */
#define DEBUG

#define MILLISECS_DIVIDE 10000L
#define VOLUME_MUTE -10000L /* Directshow's Mute Volume */

/* Defines below are for BroadcastApMessage and WM_NULL's wParam */

#define AP_SHOW 1
#define AP_CLOSE 2
#define AP_HIDE 3
#define AP_TRAY 4
#define AP_LOOP 5
#define AP_CLOSEONFINISH 6

/* Messages sent from the AudioSE DLL */

#define WM_FREEMEMMAP WM_APP+3
#define WM_CLOSESTREAM WM_APP+4
#define WM_FILEREADY WM_APP+5
#define WM_ASETHREADFINISHED WM_APP+6

/* Other custom messages */

#define WM_MAKEPLAYLIST WM_APP+7

/* Standard includes for each compilation unit */

#include <windows.h>
#include <tchar.h>
#include "ErrorMessages\\errormessages.h"
#include "resource.h"

/* bool is a C++ datatype, so we must define our own */

typedef enum {false=0, true} bool;

/* Function pointers to the DLL functions */

typedef void (WINAPI*STOPPROC)(void);
typedef DWORD (WINAPI*ASEFUNC)(LPVOID);
typedef HWND (WINAPI*UPDATEPROC)(HWND, const int);

/* Version defines */

#define AUDIOPLAYER_VERSION 980
#define VERSION_TEXT "0.9.8.0"
#define VERSION_COMMA 0,9,8,0

#ifndef LOCALE_INVARIANT /* The seems to be defined by default in VS2005 but not in Dev-Cpp */

#define LOCALE_INVARIANT MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT)
                                             
#endif /* !LOCALE_INVARIANT */

/* Macro for easy release of DirectShow/XML Interfaces */

#define SAFE_RELEASE(i) {if(i) i->lpVtbl->Release(i); i = NULL;}

/* Playlist types enumeration */

enum
{
    PLAYLIST_ERROR=0,
    PLAYLIST_M3U,
    PLAYLIST_WPL,
    PLAYLIST_ASX /* Also used for WAX, WMX, WVX files too */
};

/* Menu position enumeration (for the GetSubMenu calls) */

enum
{
	FILE_MENU=0,
	PLAYLIST_MENU,
	CONTROL_MENU,
	VOLUME_MENU,
	TOOLS_MENU,
	ABOUT_MENU
};

/* Structure to hold playlist data */

typedef struct
{
	unsigned long lNumOfFilesinPlaylist;
	TCHAR** PlaylistItems;
	unsigned long lCurrentPlayingFile;
	bool bShuffle;
	TCHAR szPlaylistPath[MAX_PATH];
} PLAYLISTDATA;

/* Structure to hold data when multiple files are selected in Explorer */

typedef struct
{
	LPTSTR szPlaylist;
	long lNumFiles;
	HWND hwnd;
	PLAYLISTDATA* pld;
} RAWDATA;

/* Structure to pass as parameter to EnumWindows
   when a second instance is opened but the "Allow Only One Instance" menu option is selected */

typedef struct
{
    LPTSTR szFileName; /* Selected file to play */
    HWND hwnd; /* Handle to this instance's main window  */
} AP_DATACOPY;

#endif /* !MASTER_H */
